
import './FormExamine.scss'

import qs from 'qs'
import { useState } from 'react'
import { Input, Button, App } from 'antd'
import { useRequest } from 'alova/client'

import { Http } from '../../API'


const { TextArea } = Input


const WarningInfo = ({ data, Off }) => {
    const { notification } = App.useApp()
    const { btnData, record, init, InitWijmo } = data
    const { url, pathArr } = btnData
    const [loading, setLoading] = useState(false)
    const [ExamineText, setExamineText] = useState('')
    const { send } = useRequest(params => Http({ url, params }), { immediate: false })
    const onSubmit = () => {
        setLoading(true)
        let params = { uuid: data.record.yS_Gid, handleNote: ExamineText || '', handled: 1 }
        send(params).then(() => {
            notification.success({
                key: 'success',
                message: '成功提醒!',
                description: '已成功提交审核信息!!',
            })
            init(InitWijmo.init, true)
            Off()
        })
    }

    return (
        <div className='WarningInfo'>
            <TextArea
                value={ExamineText}
                placeholder="请输入您的审核意见与建议"
                autoSize={{ minRows: 6, maxRows: 12 }}
                onChange={e => setExamineText(e.target.value)}
            />
            <Button type='primary' size='large' loading={loading} onClick={onSubmit}>提交审核</Button>
        </div>
    )
}


const TempMapping = {
    WarningInfo
}

const FormExamine = ({ data, Off }) => {

    // const { btnData, record, init, InitWijmo } = data
    // init(InitWijmo.init, true)
    const Template = TempMapping[data.btnData.type]

    return (
        <div className='FormExamine'>
            <Template data={data} Off={Off} />
        </div>
    );
};

export default FormExamine;